import { Component } from "react";
import "./Item.css";

export default class Item extends Component {
  constructor(props) {
    super(props);
    // console.log(props);
    this.state={
        flag:false
    }
  }
  change(id, b) {
    this.props.change(id, b)

  }
  render() {
    const { list } = this.props;
    return (
      <ul>
        {list.map((item) => {
          return (
            <li className="li" key={item.id}>
              <div className="dv1">
                <input
                  checked={item.check}
                  type="checkbox"
                  onChange={this.change.bind(this, item.id, true)}
                />
                <div>{item.title}</div>
              </div>
              <button onClick={this.change.bind(this,item.id, false)}>删除</button>
            </li>
          );
        })}
      </ul>
    );
  }
}
